//package com.mywiki.interceptor;
//
//import com.mywiki.filter.LogFilter;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.lang.Nullable;
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.HandlerInterceptor;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
///**
// * describe: 拦截器， spring框架持有得，常用于登录校验，权限校验 请求日志打印
// *
// * @author: robin
// * @date 2024/1/20 21:05
// */
//@Component
//public class LoginInterceptor implements HandlerInterceptor {
//
//    private static final Logger LOG = LoggerFactory.getLogger(HandlerInterceptor.class);
//
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        //打印请求
//        LOG.info("--------------- LoginInterceptor 开始 ----------------");
//        LOG.info("请求地址: {},{} ", request.getRequestURL().toString(), request.getMethod());
//        LOG.info("远程地址: {}", request.getRemoteAddr());
//        long startTime = System.currentTimeMillis();
//        request.setAttribute("requestStartTime", startTime);
//        return true;
//    }
//
//    @Override
//    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable ModelAndView modelAndView) throws Exception {
//        long startTime = (long)request.getAttribute("requestStartTime");
//        LOG.info("------------- LoginInterceptor 结束 耗时: {} ms -----------------", System.currentTimeMillis() -  startTime);
//    }
//
//    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable Exception ex) throws Exception {
//        LOG.info("LoginInterceptor 结束");
//    }
//
//}
